package ch.unisi.inf.gui;

import java.awt.*;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;

import javax.swing.*;

import bejar.MyCellRenderder;


public class NewFrame extends JFrame {
	
	private final static int widthframe = 900; 
	private final static int heightframe = 600; 
	static JFrame frame;
	static JList list;
	//public ListPanel list;
	
	public String[] data = {"Library"};
	
	/**
	 * @param args
	 */
	
	public NewFrame(){
		
		frame = new JFrame();
		frame.setLayout(new BorderLayout());
		frame.setSize(new Dimension( 900, 600));
		frame.setResizable(false);
		
		//list = new ListPanel(data);
		list = new JList(data);
		//list.setCell();
		//list = new ListPanel(data);
		list.setCellRenderer(new ListRenderer());
		
		
		JScrollPane scrollList = new JScrollPane(list);	
		JScrollPane scrollPhoto = new JScrollPane(new PhotoPanel());
		
		JSplitPane list_gui = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, scrollList, scrollPhoto);
		list_gui.setOneTouchExpandable(true);
		list_gui.setDividerLocation(200);
		
		frame.getContentPane().add(BorderLayout.CENTER, list_gui);
		frame.getContentPane().add(BorderLayout.SOUTH, new ButtonPanel());
		//frame.setJMenuBar(new MenuBar(null));
		
		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		frame.setVisible(true);	
		
		MouseListener mouselistener = new MouseAdapter(){
			public void mouseClicked (MouseEvent e){
				if(e.getClickCount()== 1){
					int index = list.locationToIndex(e.getPoint());
					System.out.println("Double clicked on item "+ index);
				}
				
			}
		};
		
		list.addMouseListener(mouselistener);
	}
	
	
	public static void main(String[] args) {
		NewFrame name = new NewFrame();

	}

}
